package co.fitstart.entity.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import co.fitstart.entity.principal.Principal;

/**
 * 电话拨打预约记录
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "telephone_record")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class TelephoneRecord {
    @Id
    @GeneratedValue
    private Long id;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private TelephoneResource telephoneResource;
    
    /** 前台电话接待人 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Principal receptionist;
    
    /** 接待日期 */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @org.hibernate.annotations.Type(type = "date")
    private Date receptionTime;
    
    /** 未约成功原因 */
    private String failResaon;
    
    /** 创建时间 */
    private Date createTime;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    public TelephoneRecord() {
        
    }
    
    public TelephoneRecord(TelephoneResource telephoneResource, Principal receptionist, String failResaon) {
        this.telephoneResource = telephoneResource;
        this.receptionist = receptionist;
        this.failResaon = failResaon;
    }
    
    /**
     * 
     * @return
     */
    public TelephoneRecord initilize() {
        this.receptionTime = new Date();
        this.createTime = new Date();
        this.disabled = false;
        
        return this;
    }
    
    /**
     * 
     * @param telephoneResource
     * @return
     */
    public TelephoneRecord editTelephoneResource(TelephoneResource telephoneResource) {
        this.telephoneResource = telephoneResource;
        
        return this;
    }
    
    /**
     * 
     * @param receptionist
     * @return
     */
    public TelephoneRecord editReceptionist(Principal receptionist) {
        this.receptionist = receptionist;
        
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the telephoneResource
     */
    public TelephoneResource getTelephoneResource() {
        return telephoneResource;
    }

    /**
     * @return the receptionist
     */
    public Principal getReceptionist() {
        return receptionist;
    }

    /**
     * @return the receptionTime
     */
    public Date getReceptionTime() {
        return receptionTime;
    }

    /**
     * @return the failResaon
     */
    public String getFailResaon() {
        return failResaon;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param telephoneResource the telephoneResource to set
     */
    public void setTelephoneResource(TelephoneResource telephoneResource) {
        this.telephoneResource = telephoneResource;
    }

    /**
     * @param receptionist the receptionist to set
     */
    public void setReceptionist(Principal receptionist) {
        this.receptionist = receptionist;
    }

    /**
     * @param receptionTime the receptionTime to set
     */
    public void setReceptionTime(Date receptionTime) {
        this.receptionTime = receptionTime;
    }

    /**
     * @param failResaon the failResaon to set
     */
    public void setFailResaon(String failResaon) {
        this.failResaon = failResaon;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
